package cn.com.test.kafka;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.kafka.support.KafkaHeaders;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;

public class KafkaServiceImpl {

	@Autowired
    @Qualifier("inputToKafka")
    MessageChannel channel;
	
	public void sendUserInfo(String key, Object obj) {
        Message msg = MessageBuilder.withPayload(obj)
                .setHeader("kafkaUser", key)
                .setHeader(KafkaHeaders.TOPIC, "test").build();
        channel.send(msg);
    }
}
